<template>
  <div>
    <van-nav-bar
      title="修改行吧"
      left-text="返回"
      right-text="确认"
      left-arrow
      @click-left="onClickLeft"
      @click-right="onClickRight"
    />
    <van-field name="radio" label="单选框">
      <template #input>
        <van-radio-group v-model="radio" direction="horizontal">
          <van-radio name="0">男</van-radio>
          <van-radio name="1">女</van-radio>
        </van-radio-group>
      </template>
    </van-field>
  </div>
</template>

<script>
import { lglDiZhiXiuGai } from "../util/http";
export default {
  name: "",
  components: {},
  props: {},
  data() {
    return {
      radio: "1",
    };
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    //返回按钮
    onClickLeft() {
      this.$router.go(-1);
    },
    //确认按钮
    async onClickRight() {
      console.log(this.radio);
      let data = {
        sex: this.radio,
      };
      await lglDiZhiXiuGai(data).then((res) => {
        console.log(res);
        this.$toast.success({
          message: "修改成功",
        });
        let userInfo = JSON.parse(window.sessionStorage.getItem("user"));
        userInfo.sex = this.radio;
        window.sessionStorage.setItem("user", JSON.stringify(userInfo));
        this.$router.push("/selfInfo")
      });
    },
  },
};
</script>

<style scoped >
</style>
